package co.fitstart.entity.market.template;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.OrderBy;
import org.hibernate.annotations.Where;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * 每周课件
 * 
 * @author dan
 *
 */
@Entity
@Table(name = "market_batch_courseware_template")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class MarketBatchCoursewareTemplate {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 课件名称 */
    private String name;
    
    /** 周数 */
    private int sorting;
    
    /** 描述 */
    private String description;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private MarketMonthlyCoursewareTemplate monthly;
    
    @OneToMany(mappedBy = "batch", fetch = FetchType.LAZY)
    @Where(clause = "is_disabled = 0")
    @OrderBy(clause = "sorting ASC")
    @JSONField(serialize = false)
    private List<MarketDailyCoursewareTemplate> dailycoursewares;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public MarketBatchCoursewareTemplate() {
        
    }
    
    /**
     * 
     * @param name
     * @param sorting
     * @param description
     * @param course
     */
    public MarketBatchCoursewareTemplate(String name, int sorting, String description, MarketMonthlyCoursewareTemplate monthly) {
        this.name = name;
        this.sorting = sorting;
        this.description = description;
        this.monthly = monthly;
        this.disabled = false;
    }
    
    /**
     * 
     * @return
     */
    public MarketBatchCoursewareTemplate disable() {
        this.disabled = true;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the sorting
     */
    public int getSorting() {
        return sorting;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @return the monthly
     */
    public MarketMonthlyCoursewareTemplate getMonthly() {
        return monthly;
    }

    /**
     * @return the dailycoursewares
     */
    public List<MarketDailyCoursewareTemplate> getDailycoursewares() {
        return dailycoursewares;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param sorting the sorting to set
     */
    public void setSorting(int sorting) {
        this.sorting = sorting;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @param monthly the monthly to set
     */
    public void setMonthly(MarketMonthlyCoursewareTemplate monthly) {
        this.monthly = monthly;
    }

    /**
     * @param dailycoursewares the dailycoursewares to set
     */
    public void setDailycoursewares(List<MarketDailyCoursewareTemplate> dailycoursewares) {
        this.dailycoursewares = dailycoursewares;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
